#include "animal.h"

static animal_klass_info local_animal_klass = {animal_init};
animal_klass_info* animal_klass = &local_animal_klass;

static animal* animal_ctor(animal* self)
{
	memset(self->name, 0x00, sizeof(self->name));
	self->weight = 0;
	return self;
}

static animal* animal_dtor(animal* self)
{
	return self;
}

static char* local_animal_move(animal* self)
{
	(void)self;
	return "unknown";
}

void animal_init(void)
{
	if(KLASS(animal_klass)->init)
	{
		KLASS(animal_klass)->init = NULL;
		KLASS(animal_klass)->super = NULL;
		KLASS(animal_klass)->name = "animal_klass";
		KLASS(animal_klass)->size = sizeof(animal);
		KLASS(animal_klass)->ctor = animal_ctor;
		KLASS(animal_klass)->dtor = animal_dtor;
		animal_klass->move = local_animal_move;
	}
}

char* animal_get_name(animal* self)
{
	return self->name;
}

void animal_set_name(animal* self, char* name)
{
	strncpy(self->name, name, sizeof(self->name));
}

int animal_get_weight(animal* self)
{
	return self->weight;
}

void animal_set_weight(animal* self, int weight)
{
	self->weight = weight;
}

char* animal_move(animal* self)
{
	return ANIMAL_KLASS(klass_of(self))->move(self);
}
